﻿using Teigha.TD;

namespace OdaOperation.Core.Creators
{
    public abstract class BaseCreator
    {
        protected OdDbDatabase m_database;

        protected string m_layerName;

        protected OdDbObjectId m_blockTableId;

        protected OdDbObjectId GetActiveBlock()
        {
            OdDbObjectId odDbObjectId = m_database.getActiveLayoutBTRId();
            if (odDbObjectId == m_database.getPaperSpaceId())
            {
                OdDbViewport odDbViewport = m_database.activeViewportId().safeOpenObject() as OdDbViewport;
                if (odDbViewport.number() > 1)
                {
                    odDbObjectId = m_database.getModelSpaceId();
                }
            }

            return odDbObjectId;
        }

        public BaseCreator(OdDbDatabase pDb)
        {
            m_database = pDb;
        }

        public BaseCreator(OdDbDatabase pDb, OdDbObjectId blockTableId)
        {
            m_database = pDb;
            m_blockTableId = blockTableId;
        }

        public BaseCreator(OdDbDatabase pDb, OdDbObjectId blockTableId, string layerName)
        {
            m_database = pDb;
            m_blockTableId = blockTableId;
            m_layerName = layerName;
        }

        public BaseCreator(OdDbDatabase pDb, string layerName)
        {
            m_database = pDb;
            m_layerName = layerName;
        }
    }
}

